from django.db import models

# Create your models here.
class Sala(models.Model):
    nome = models.CharField(max_length=128, blank=False)
    capacidade = models.PositiveIntegerField(default=0)
    
    def __unicode__(self):
        return '%s (%s)' % (self.nome,self.capacidade)
        
    class Meta:
        ordering = ['nome']

class Evento(models.Model):
    nome = models.CharField(max_length=256, blank=False)
    dt_evento = models.DateField(verbose_name=u'Data')
    participantes = models.PositiveIntegerField(default=0)
    #sala = models.ForeignKey(Sala, unique_for_date=dt_evento)
    #sala = models.ForeignKey(Sala)

    def __unicode__(self):
        return '%s (%s)' % (self.nome,self.dt_evento)

#    class Meta:
#        ordering = ['dt_evento', 'sala']
#        unique_together = ['dt_evento','sala']

class Reserva(models.Model):
    responsavel = models.CharField(max_length=256, blank=False)
    sala = models.ForeignKey(Sala)
    evento = models.ForeignKey(Evento)

    #def __unicode__(self):
    #    return unicode(self.evento)
        
    class Meta:
        unique_together = ['sala','evento']